I'm using windows api to create a fullscreen window, but this code just changes my screen resolution but fails to create the window:

(it's 99% example code so don't blame me for the ugly mess, I'm gonna clean it up when I get it working)

Code:
#include <windows.h>
#include <gl/gl.h>

#define WIDTH 1024
#define HEIGHT 768

LRESULT CALLBACK WndProc (HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam);
void EnableOpenGL (HWND hWnd, HDC *hDC, HGLRC *hRC);
void DisableOpenGL (HWND hWnd, HDC hDC, HGLRC hRC);

int WINAPI WinMain (HINSTANCE inst, HINSTANCE pinst, char *cmd, int cs)
{
    WNDCLASS wc;
    HWND hwnd;
    HDC hdc;
    HGLRC hrc;        
    MSG msg;
    DEVMODE dmScreenSettings;


    // register window class 
    wc.style = CS_OWNDC;
    wc.lpfnWndProc = WndProc;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hInstance = inst;
    wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = NULL;
    wc.lpszMenuName = NULL;
    wc.lpszClassName = "GLSample";
    RegisterClass (&wc);

    // create main window
    hwnd = CreateWindowEx(WS_EX_APPWINDOW, 
      "GLSample", "OpenGL Sample", 
      WS_POPUP | WS_CLIPSIBLINGS,
      0, 0, WIDTH, HEIGHT,
      NULL, NULL, inst, NULL);
      
    memset(&dmScreenSettings,0,sizeof(dmScreenSettings));			
	dmScreenSettings.dmSize		= sizeof(dmScreenSettings);					
	dmScreenSettings.dmPelsWidth	= WIDTH;						
	dmScreenSettings.dmPelsHeight	= HEIGHT;					
	dmScreenSettings.dmBitsPerPel	= 16;							
	dmScreenSettings.dmFields	= DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
	
	ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN);
    /* enable OpenGL for the window */
    EnableOpenGL(hwnd, &hdc, &hrc);

    /* program main loop */
    while (1)
    {
        /* check for messages */
        if (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
        {
            /* handle or dispatch messages */
            if (msg.message == WM_QUIT)
            {
                break;
            }
            else
            {
                TranslateMessage (&msg);
                DispatchMessage (&msg);
            }
        }
        else
        {
            /* OpenGL animation code goes here */

            glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
            glClear (GL_COLOR_BUFFER_BIT);

            glPushMatrix ();
            glRotatef (0, 0.0f, 0.0f, 1.0f);
            glBegin (GL_TRIANGLES);
            glColor3f (1.0f, 0.0f, 0.0f);   glVertex2f (0.0f, 1.0f);
            glColor3f (0.0f, 1.0f, 0.0f);   glVertex2f (0.87f, -0.5f);
            glColor3f (0.0f, 0.0f, 1.0f);   glVertex2f (-0.87f, -0.5f);
            glEnd ();
            glPopMatrix ();

            SwapBuffers (hdc);

         
            Sleep (1);
        }
    }
    
    ChangeDisplaySettings(NULL,0);	

    /* shutdown OpenGL */
    DisableOpenGL (hwnd, hdc, hrc);

    /* destroy the window explicitly */
    DestroyWindow (hwnd);

    return msg.wParam;
}


/* window procedure */

LRESULT CALLBACK WndProc (HWND hWnd, UINT message,
                          WPARAM wParam, LPARAM lParam)
{
    switch (message) {
        case WM_CREATE:
            return 0;
        case WM_CLOSE:
            PostQuitMessage (0);
            return 0;
        case WM_DESTROY:
            return 0;
        case WM_KEYDOWN:
            switch (wParam) {
                case VK_ESCAPE: PostQuitMessage(0); return 0;
            }
            return 0;
        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
    }
}


/*******************
 * Enable OpenGL
 *
 *******************/

void EnableOpenGL (HWND hWnd, HDC *hDC, HGLRC *hRC)
{
 	PIXELFORMATDESCRIPTOR pfd;
	int format;
	*hDC=GetDC(hWnd);											

	//Set the pixel format for the DC
	memset(&pfd,0,sizeof(pfd));
	pfd.nSize = sizeof(pfd);									
	pfd.nVersion = 1;										
	pfd.dwFlags = PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER; 
	pfd.iPixelType = PFD_TYPE_RGBA;
	pfd.cColorBits = 24;										
	pfd.cDepthBits = 16;							

	format = ChoosePixelFormat(*hDC,&pfd);
	SetPixelFormat(*hDC,format,&pfd);								
 
	*hRC=wglCreateContext(*hDC);									
	wglMakeCurrent(*hDC,*hRC);
}


// Disable OpenGL


void DisableOpenGL (HWND hWnd, HDC hDC, HGLRC hRC)
{
    wglMakeCurrent(NULL, NULL);
    wglDeleteContext(hRC);
    ReleaseDC(hWnd, hDC);
}
what's wrong with it?